package com.mikao.controller;

import com.mikao.dto.bo.DoFruitForm;
import com.mikao.dto.bo.DoTreeForm;
import com.mikao.dto.vo.*;
import com.mikao.service.IndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Scope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(description = "种植首页  ")
@RestController
@RequestMapping("/index")
@Scope("prototype")
@Validated
public class IndexController extends BaseController {

    private IndexService indexService;

    public IndexController(IndexService indexService) {
        this.indexService = indexService;
    }

    @ApiOperation("首页种植展示")
    @GetMapping("/auth/index")
    public BaseResult<PlantDto> index() {
        return indexService.index(getUserId());
    }

    @ApiOperation("我的果树")
    @GetMapping("/auth/myTree")
    public BaseResult<List<MyTreeDto>> myTree() {
        return indexService.myTree(getUserId());
    }

    @ApiOperation("果树操作")
    @PostMapping("/auth/doTree")
    public BaseResult doTree(@RequestBody DoTreeForm doTreeForm) {
        return indexService.doTree(doTreeForm);
    }

    @ApiOperation("收获列表")
    @GetMapping("/auth/getFruit")
    public BaseResult<List<FruitDto>> getFruit() {
        return indexService.getFruit(getUserId());
    }

    @ApiOperation("果子操作")
    @PostMapping("/auth/doFruit")
    public BaseResult doFruit(@RequestBody DoFruitForm doFruitForm) {
        return indexService.doFruit(getUserId(), doFruitForm);
    }

    @ApiOperation("钱包")
    @GetMapping("/auth/wallet")
    public BaseResult<WalletDto> wallet() {
        return indexService.wallet(getUserId());
    }

    @ApiOperation("大图，我的果树数量")
    @GetMapping("/auth/myTreeCount")
    public BaseResult<Integer> myTreeCount() {
        return indexService.myTreeCount(getUserId());
    }
}
